package com.androider.timememory.db;

import com.androider.timememory.utils.Dict;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DataBaseHelper extends SQLiteOpenHelper {
	private static final String DATABASE_NAME = "timememory.db";
	private static final int DATABASE_VERSION =1;
	
	public DataBaseHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
		
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		
		db.execSQL("CREATE TABLE IF NOT EXISTS " + Dict.T_record + "("
		        + Dict.C_id + " INTEGER PRIMARY KEY AUTOINCREMENT,"
		        + Dict.C_category + " NTEXT,"
		        + Dict.C_type + " INTEGER,"
		        + Dict.C_content + " NTEXT,"
		        + Dict.C_date + " NTEXT,"
		        + Dict.C_note + " NTEXT"
		        + ");");
		
		db.execSQL("CREATE TABLE IF NOT EXISTS " + Dict.T_whitelist + "("
		        + Dict.C_name + " NTEXT,"
		        + Dict.C_number + " NTEXT"
		        + ");");
		
//		db.execSQL("CREATE TABLE IF NOT EXISTS " + Dict.T_whitelist + "("
//				+ Dict.C_id + " INTEGER PRIMARY KEY AUTOINCREMENT,"
//				+ Dict.C_name + " NTEXT,"
//				+ Dict.C_number + " NTEXT"
//				+ ");");
		
//		db.execSQL("CREATE TABLE IF NOT EXISTS " + T_record + "("
//				+ C_id + " INTEGER PRIMARY KEY AUTOINCREMENT,"
//				+ C_category + " NTEXT,"
//				+ C_type + " INTEGER,"
//				+ C_content + " NTEXT,"
//				+ C_date + " NTEXT,"
//				+ C_place + " NTEXT,"
//				+ C_people + " NTEXT,"
//				+ C_note + " NTEXT"
//				+ ");");
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL("DROP TABLE IF EXISTS" + Dict.T_record);
		db.execSQL("DROP TABLE IF EXISTS" + Dict.T_whitelist);
		onCreate(db);
	}

}
